package com.xywh.micro_warehousing.mvp.ui.adapter;

import android.content.Context;
import android.support.annotation.Nullable;
import android.view.View;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.xywh.micro_warehousing.R;
import com.xywh.micro_warehousing.mvp.ui.entity.Tab1;

import org.simple.eventbus.EventBus;

import java.util.List;

/**
 * @ProjectName:
 * @ackage: com.xywh.micro_warehousing.mvp.ui.adapter
 * @ClassName: MaterialsAdapter
 * @Description: 三级：物料的信息，名称、数量、单位、申请预留功能
 * @Author: 小星
 * @CreateDate: 2020/6/22 0022 14:09
 * @UpdateUser: 更新者：
 * @UpdateDate: 2020/6/22 0022 14:09
 * @UpdateRemark: 更新说明：
 * @Version: 1.0
 */
public class MaterialsAdapter extends BaseQuickAdapter<Tab1.DataBean.CountersBean.MaterialsBean, BaseViewHolder> {

    private Context mContext;
    private String mCounterId;

    public MaterialsAdapter(Context context, @Nullable List<Tab1.DataBean.CountersBean.MaterialsBean> data, String counterId) {
        super(R.layout.item_materials, data);
        this.mContext = context;
        this.mCounterId = counterId;
    }

    @Override
    protected void convert(BaseViewHolder helper, Tab1.DataBean.CountersBean.MaterialsBean item) {
        //GlideUtil.loadImage(mContext,item.getImg(),helper.getView(R.id.img_head));
        helper.setText(R.id.tv_ming_cheng, "物料名称：" + item.getMaterial());
        helper.setText(R.id.tv_shu_liang, "数量：" + item.getStoreNum());
        helper.setText(R.id.tv_dan_wei, "单位：" + item.getUnit());

        helper.setOnClickListener(R.id.btn_shen_qing_yu_liu, new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                item.setCounterId(mCounterId);
                EventBus.getDefault().post(item, "shenQingYuLiu");
            }
        });

    }

}
